package com.plm.k8s.myk8sapi.cmd.impl;

import com.plm.k8s.myk8sapi.cmd.AbstractLocalCmd;
import com.plm.k8s.myk8sapi.cmd.IVersionCmd;
import com.plm.k8s.myk8sapi.pojo.entity.version.VersionEntity;
import org.springframework.stereotype.Service;

/**
 * @author 潘磊明
 * 版本号：1.0
 * 创建日期：2021/7/15 17:25
 */
@Service
public class VersionCmdImpl extends AbstractLocalCmd implements IVersionCmd {

    @Override
    public VersionEntity version() throws Exception {
        String str = generateVersionCmd();
        VersionEntity version = execForYamlObject(str, VersionEntity.class);
        return version;
    }

    private String generateVersionCmd() {
        StringBuilder sb = new StringBuilder(generateKubeCmdBase());
        sb.append("version -o yaml");
        return sb.toString();
    }
}
